package com.itqf.controller;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;

/**
 * projectName: springmvc2103
 *
 * @author: 赵伟风
 * time: 2021/7/5 17:57
 * description: 文件上传接受的controller
 */

@RestController
@RequestMapping("file")
public class FileUploadController {


    @PostMapping("up")
    public Object  upfile(MultipartFile ergouzi) throws IOException {


        System.out.println("ergouzi = " + ergouzi);

        //获取文件名
        String originalFilename = ergouzi.getOriginalFilename(); //获取文件名
        String name = ergouzi.getName(); //input输入框 name值  ergouzi
        //将文件写到指定得磁盘
        ergouzi.transferTo(new File("D:/temp/"+originalFilename));

        return "保存成功!";
    }
}
